package com.zhongfeng.api.modules.ip.controller;

import com.zhongfeng.api.modules.end.vo.params.EndParams;
import com.zhongfeng.api.modules.ip.service.IpService;
import com.zhongfeng.api.modules.ip.vo.params.IpParams;
import com.zhongfeng.api.modules.utils.pojo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/ip")
public class IpController {

    @Autowired
    private IpService ipService;

    /**
     * 查询全部IP地址
     * @param params
     * @return
     */
    @PostMapping("/queryAllIp")
    public Result queryAllIp(@RequestBody IpParams params) {
        return ipService.queryAllIp(params);
    }

    /**
     * 新增IP地址
     * @param params
     * @return
     */
    @PostMapping("/addIp")
    public Result addIp(@RequestBody IpParams params){
        return ipService.addIp(params);
    }

    /**
     * 删除IP地址
     * @param params
     * @return
     */
    @PostMapping("/deleteIp")
    public Result deleteIp(@RequestBody EndParams params){
        return ipService.deleteIp(params.getIpId());
    }

    /**
     * 修改IP地址
     * @param params
     * @return
     */
    @PostMapping("/updateIp")
    public Result updateIp(@RequestBody IpParams params){
        return ipService.updateIp(params);
    }

    /**
     * 查询全部IP类型
     * @param params
     * @return
     */
    @PostMapping("/queryAllIpType")
    public Result queryAllIpType(@RequestBody IpParams params) {
        return ipService.queryAllIpType(params);
    }
}
